package com.study.service;

import com.study.dao.UserDao;
import com.study.dao.UserDaoMySQLImpl;

public class UserServiceImpl implements UserService {


    //控制反转的方式
    private UserDao userDao;

    public UserDao getUserDao() {
        return userDao;
    }
    //主要就是通过了间接的set方法，实现控制反转
    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    public void findUser() {

        userDao.getUser();

        //以前的方式我们需要通过程序更改来改变选取的数据访问方式
//        UserDao userDao = new UserDaoMySQLImpl();
//        userDao.getUser();

//        UserDao userDao2 = new UserDaoMySQLImpl();
//        userDao2.getUser();

    }

}
